package com.sound.service;

import com.hoangkien.soundcloud.R;

import android.app.Service;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.Binder;
import android.os.IBinder;

public class MyService extends Service{
	private final IBinder mBinder = new LocalBinder();
	private MediaPlayer mp;

	@Override
	public IBinder onBind(Intent intent) {
		return mBinder;
	}
	
	@Override
	public void onCreate() {
		super.onCreate();
		mp = MediaPlayer.create(this, R.raw.chac_ai_do_se_ve);
	}
		
	public void playMusic() {
		mp.start();
	}
	
	public void pauseMusic() {
		if(mp.isPlaying()){
			mp.pause();
		}
	}
	
	public void stopMusic() {
		if(mp.isPlaying()){
			mp.stop();
			mp = MediaPlayer.create(this, R.raw.chac_ai_do_se_ve);
		}
	}
	
	public class LocalBinder extends Binder{
		public MyService getMyService(){
			return MyService.this;
		}
	}

}
